package com.lry.basic.jvm.asm.transform_class.demo3;

import aj.org.objectweb.asm.ClassVisitor;
import aj.org.objectweb.asm.FieldVisitor;

public class RemoveFieldVisitor extends ClassVisitor {

    private final String fieldName;
    private final String fieldDesc;


    public RemoveFieldVisitor(int api, ClassVisitor cv,String fieldName,String fieldDesc) {
        super(api,cv);
        this.fieldDesc = fieldDesc;
        this.fieldName = fieldName;
    }


    @Override
    public FieldVisitor visitField(int access, String name, String descriptor, String signature, Object value) {
        if (name.equals(fieldName) && descriptor.equals(fieldDesc)) {
            return null;
        }
        return super.visitField(access, name, descriptor, signature, value);
    }

}
